package de.fhhof.robot.control.app;

import java.util.Observable;
import java.util.Observer;

import de.fhhof.robot.control.IMessage;
import de.fhhof.robot.control.cmd.AbstractCommand;
import de.fhhof.robot.control.cmd.CmdInvoker;
import de.fhhof.robot.control.cmd.SAPCommandFactory;


public class CommandProcessor implements Observer{

	@Override
	public void update(Observable src, Object msg) {
		
		if(msg instanceof IMessage){
			
			IMessage message = (IMessage) msg;
			
			AbstractCommand cmd = SAPCommandFactory.createCommand(message);
			
			CmdInvoker invoker = new CmdInvoker(cmd);
			Thread thread = new Thread(invoker);
			thread.start();
		
		}
		
	}

}
